package com.example.service;

import com.example.entity.Account;
import com.example.entity.PetReus;
import com.example.mapper.PetReusMapper;
import com.example.utils.TokenUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author HY
 * @date 2025/2/15
 */
@Service
public class PetReusService {
    @Autowired
    private PetReusMapper petReusMapper;


    public void add(PetReus petReus) {
        Account currentUser = TokenUtils.getCurrentUser();
        petReus.setUserId(currentUser.getId().toString());
        petReusMapper.insert(petReus);
    }

    public PageInfo<PetReus> selectPage(PetReus petReus, Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageNum, pageSize);
        PageInfo<PetReus> pageInfo = PageInfo.of(petReusMapper.selectAll(petReus));
        return pageInfo;
    }
}
